package com.ruibang.glass.produce.controller.lh;

import com.ruibang.glass.produce.domain.req.AnalysisReportReq;
import com.ruibang.glass.produce.entity.AnalysisReport;
import com.ruibang.glass.produce.service.AnalysisReportService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import javax.validation.Valid;


/**
 * <p>
 * 质量-理化-理化分析报告 前端控制器
 * </p>
 *
 * @author songJinKang
 * @since 2024-03-22
 */
@RestController

@RequestMapping("/api/glass/produce/lh/analysisReport")
@Api(value = "质量-理化-理化分析报告控制器", tags = {"质量-理化-理化分析报告接口"})
public class AnalysisReportController {

    @Autowired
    private AnalysisReportService analysisReportService;

    @GetMapping("/getDetails/{id}")
    @ApiOperation(value = "获取质量-理化-理化分析报告", notes = "获取质量-理化-理化分析报告")
    public ResultBody getDetails(@PathVariable(value = "id") String id) {
        return ResultBody.success(analysisReportService.getDetails(id));
    }

    @GetMapping("/getById/{id}")
    @ApiOperation(value = "获取质量-理化-理化分析报告", notes = "获取质量-理化-理化分析报告")
    public ResultBody getById(@PathVariable(value = "id") String id) {
        return ResultBody.success(analysisReportService.getById(id));
    }

    @PostMapping("/save")
    @ApiOperation(value = "新增质量-理化-理化分析报告", notes = "新增质量-理化-理化分析报告")
    public ResultBody save(@RequestBody @Valid AnalysisReport analysisReport) {
        analysisReportService.insert(analysisReport);
        return ResultBody.success();
    }

    @GetMapping("/deleteById/{id}")
    @ApiOperation(value = "通过ID删除质量-理化-理化分析报告", notes = "通过ID删除质量-理化-理化分析报告")
    public ResultBody delete(@PathVariable(value = "id") String id) {
        analysisReportService.delete(id);
        return ResultBody.success();
    }

    @PostMapping("/edit")
    @ApiOperation(value = "修改质量-理化-理化分析报告", notes = "修改质量-理化-理化分析报告")
    public ResultBody updateById(@RequestBody AnalysisReport analysisReport) {
        analysisReportService.edit(analysisReport);
        return ResultBody.success();
    }

    @PostMapping("/pageQuery")
    @ApiOperation(value = "分页列表查询质量-理化-理化分析报告", notes = "分页列表查询质量-理化-理化分析报告")
    public ResultBody<IPage<AnalysisReport>> pageQuery(@RequestBody AnalysisReportReq analysisReportReq) {
        return ResultBody.success(analysisReportService.pageQuery(analysisReportReq));
    }
}
